package com.cw.jeeyt.common.enums;

import java.io.Serializable;

import com.cw.lang.common.enums.IEnum;

import lombok.Getter;
import lombok.ToString;

/**
 * mysql数据类型
 */
@Getter
@ToString
public enum EnumMysqlDataType implements IEnum, Serializable {
    /** CHAR **/
    CHAR("01", "CHAR","char类型"),
    /** VARCHAR **/
    VARCHAR("02", "VARCHAR","varchar类型"),
    /** INT **/
    INT("03", "INT","int类型"),
    /** TINYTEXT **/
    TINYTEXT("04", "TINYTEXT","TINYTEXT类型"),
    /** TEXT **/
    TEXT("05", "TEXT","TEXT类型"),
    /** BLOB **/
    BLOB("06", "BLOB","BLOB类型"),
    /** MEDIUMTEXT **/
    MEDIUMTEXT("07", "MEDIUMTEXT","MEDIUMTEXT类型"),
    /** MEDIUMBLOB **/
    MEDIUMBLOB("08", "MEDIUMBLOB","MEDIUMBLOB类型"),
    /** LONGTEXT **/
    LONGTEXT("09", "LONGTEXT","LONGTEXT类型"),
    /** LONGBLOB **/
    LONGBLOB("10", "LONGBLOB","LONGBLOB类型"),
    /** TINYINT **/
    TINYINT("11", "TINYINT","TINYINT类型"),
    /** SMALLINT **/
    SMALLINT("12", "SMALLINT","SMALLINT类型"),
    /** MEDIUMINT **/
    MEDIUMINT("13", "MEDIUMINT","MEDIUMINT类型"),
    /** BIGINT **/
    BIGINT("14", "BIGINT","BIGINT类型"),
    /** FLOAT **/
    FLOAT("15", "FLOAT","FLOAT类型"),
    /** DOUBLE **/
    DOUBLE("16", "DOUBLE","DOUBLE类型"),
    /** DECIMAL **/
    DECIMAL("17", "DECIMAL","DECIMAL类型"),
    /** DATE **/
    DATE("18", "DATE","DATE类型"),
    /** DATETIME **/
    DATETIME("19", "DATETIME","DATETIME类型"),
    /** TIMESTAMP **/
    TIMESTAMP("20", "TIMESTAMP","TIMESTAMP类型"),
    /** TIME **/
    TIME("21", "TIME","TIME类型"),
    /** YEAR **/
    YEAR("22", "YEAR","YEAR类型"),
    /** INTEGER **/
    INTEGER("23", "INTEGER","INTEGER类型");
    /** 编码 **/
    private String code;
    /** 值 */
    private String value;
    /** 描述 **/
    private String description;

    /**
     * 私有构造方法
     *
     * @param code 编码
     * @param description 描述
     **/
    EnumMysqlDataType(String code, String value,String description) {
        this.code = code;
        this.value = value;
        this.description = description;
    }

    /**
     * 根据编码查找枚举
     *
     * @param code 编码
     **/
    public static EnumMysqlDataType find(String code) {
        for (EnumMysqlDataType frs : EnumMysqlDataType.values()) {
            if (frs.getCode()
                .equals(code)) {
                return frs;
            }
        }
        return null;
    }
    /**
     * 根据编码查找枚举
     *
     * @param value 编码
     **/
    public static EnumMysqlDataType findByValue(String value) {
        for (EnumMysqlDataType frs : EnumMysqlDataType.values()) {
            if (frs.getValue()
                    .equals(value)) {
                return frs;
            }
        }
        return null;
    }
}
